package personalisation;

import java.io.File;
import java.io.IOException;

import menu.MenuCouleur;
import menu.MenuDifficulte;
import menu.MenuMode;

import org.eclipse.swt.widgets.Shell;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.tiled.TiledMap;

import jeu.Niveau;

public class NiveauPersonalise extends Niveau {


	public NiveauPersonalise() throws SlickException {
		
		//Runtime.getRuntime().exec("nbniveaureparationp.bat");
		

		System.out.println(MenuModePersonalise.getMode());
		
		if (MenuModePersonalise.getMode() == 0) {
			File f = new File("../ressources/personalisation_construction");
			String[] lvls = f.list();
			NB_NIVEAUX_CONSTRUCTION = lvls.length-1;
			maps = new TiledMap[NB_NIVEAUX_CONSTRUCTION];
			if (NB_NIVEAUX_CONSTRUCTION >= 1) {
				for (int i = 0; i < NB_NIVEAUX_CONSTRUCTION; i++) {
					File map = new File("../ressources/personalisation_construction/Construction_Niveau"+(i+1)+".tmx");
					System.out.println(map.exists());
					if (map.exists()) {
						maps[i] = new TiledMap("../ressources/personalisation_construction/Construction_Niveau"+(i+1)+".tmx");
					}
				}
			}
		}
		else if (MenuModePersonalise.getMode() == 1) {
			File f = new File("../ressources/personalisation_reparation");
			String[] lvls = f.list();
			NB_NIVEAUX_REPARATION = lvls.length-1;
			maps = new TiledMap[NB_NIVEAUX_REPARATION];
			if (NB_NIVEAUX_REPARATION >= 1) {
				for (int i = 0; i < NB_NIVEAUX_REPARATION; i++) {
					File map = new File("../ressources/personalisation_reparation/Reparation_Niveau"+(i+1)+".tmx");
					System.out.println(map.exists());
					if (map.exists()) {
						maps[i] = new TiledMap("../ressources/personalisation_reparation/Reparation_Niveau"+(i+1)+".tmx");
					}
				}
			}
		}
		
		niveauCourant = maps[0];

		setCaseDepart();
		setCaseArrivee();
		blocked = new boolean[niveauCourant.getWidth()][niveauCourant.getHeight()];
		setBlocked();

		finished = false;

		matrice = new String[niveauCourant.getHeight()][niveauCourant.getWidth()];
		setMatrice();
	}


}
